<template>
	<view class="approval-list">
		<view class="ctn_header">
			<!-- <view class="filter">
				<view class="filter_title">
					<view class="title_item">
						全部类别
					</view>
					<image src="../../static/bg/TriangleActive.png" mode=""></image>
				</view>
				<view class="filter_title">
					<view class="title_item">
						状态
					</view>
					<image src="../../static/bg/TriangleActive.png" mode=""></image>
				</view>
			</view> -->
			<!-- <liuyuno-tabs  :tabData="tabs" :defaultIndex="defaultIndex" @tabClick='tabClick' /> -->
		<liuyuno-tabs :isShowTap="false" @confirm='confirmDate' @rest='restSearch'></liuyuno-tabs>
		</view>
		<!-- :start="item.start" :end="item.end" -->
		<view class="ctn_middlee">
			<view v-for="(item, index) in listData" :key="index" v-if="listData.length!=0">
				<record-quit :status="item.approve_state" :propTitlel="item.apply_date" :reason="item.reason" :showBtn='item.approve_state==-1' @confirm='confirmAdvice(item.pk_hi_stapply)' @prograss='checkPrograss(item.pk_hi_stapply)'></record-quit>
			</view>
		</view>
		<view class="jumpHome" @click="jumpHome">首页</view>
	</view>
</template>

<script>
import utils from '../../../common/utils/utils.js'
import service from '../../../common/service/new_file.js';
import apiData from '../../../common/utils/apiData.js';
export default {
	data() {
		return {
			tabs: ['待审核', '已审核'],
			defaultIndex: 0,
			form: {
				startTime: "",
				endTime: ""
			},
			leaveTypeOptions:[],
			listData: [],
		};
	},
	methods: {
		jumpHome(){
			uni.navigateTo({
				url:'../../home/home'
			})
		},
		checkPrograss(pk){
			uni.navigateTo({
				url:'../../attendance/attendacePrograss?pk='+pk+'&billtype=6115'
			})
		},
		confirmAdvice(pk){
			let _this = this;
			let data = apiData.adviceApproval(pk,"6115");
			service.common(data, {
				success: function(res) {
					uni.showToast({
						title:'提交成功',
					})
					setTimeout(()=>{
						_this.getLeaveRecord();
					},500)
				},
				fail: function(res) {
				}
			});
		},
		confirmDate(time){
			this.form.startTime =time[0]+' '+'00:00:00'
			this.form.endTime =time[1]+' '+"23:59:59"
			this.getLeaveRecord();
		},
		restSearch(){
			this.form.startTime=''
			this.form.startTime=''
			this.getLeaveRecord()
		},
		getLeaveRecord() {
			let _this = this;
			let data = apiData.getLeaveRecord("6115",this.form.startTime,this.form.endTime);
			service.common(data, {
				success: res => {
					console.log(res)
					let newArr = []
					res.data.VALUES.forEach(item => {
						newArr.push(item)
					});
					newArr[0].reason = {
						memo:res.data.VALUES[0].memo,
						sreason:res.data.VALUES[0].sreason.name
					}
					this.listData = newArr
				}
			});
		},
		tabClick(e) {
			// if(e=='0'){
			// 	console.log('全部')
			// }else if(e=='2'){
			// 	console.log('待审核')
			// }else if(e=='1'){
			// 	console.log('已审核')
			// }
		}
	},
	onReady() {
		// let month=new Date().getMonth()+1
		// if(month<10){
		// 	month='0'+month
		// }
		// this.form.startTime = new Date().getFullYear()+'-'+month+'-'+'01 01:00:00'
		// this.form.endTime = new Date().getFullYear()+'-'+month+'-'+new Date().getDate()+' '+'01:00:00'
		this.getLeaveRecord()
		// this.getAllLeaveType()
	},
	onLoad() {
		
	}
};
</script>

<style lang="scss" scoped>
	.jumpHome{
		width: 80rpx;
		position: fixed;
		bottom: 350rpx;
		right:20rpx;
		height: 40rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		border-radius: 16rpx;
		background: #a7a7a7;
		color: #F1F1F1;
		font-size: 24rpx;
	}
.approval-list {
	height: 100vh;
	display: flex;
	background: #f7f7f7;
	flex-direction: column;
	.ctn_header {
	}

	.ctn_middlee {
		flex: 1;
		padding: 0 36rpx;
		margin-top: 140rpx;
		overflow: scroll;
	}
}
</style>
